package com.example.luccc.bmobdemo.Activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;

import com.example.luccc.bmobdemo.Model.Person;
import com.example.luccc.bmobdemo.R;

import cn.bmob.v3.Bmob;
import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.SaveListener;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Bmob.initialize(this,"2f770400923eb349ba3c4640f4f92177");

        Person person=new Person();
        person.setName("luccc");
        person.setAddress("Guet");
        Person p2=new Person();
        p2.setName("陆乘胜");
        p2.setAddress("22DONG501");


        person.save(new SaveListener<String>() {
            @Override
            public void done(String s, BmobException e) {
             if (e!=null){
                 Toast.makeText(MainActivity.this,"成功插入",Toast.LENGTH_LONG).show();

             }
            }
        });

        p2.save(new SaveListener<String>() {
            @Override
            public void done(String s, BmobException e) {
                if (e==null){
                    Toast.makeText(getApplicationContext(),"success add data！"+s,
                            Toast.LENGTH_SHORT).show();
                }
            }
        });
    }
}
